package cn.iocoder.yudao.module.member.controller.app.mpshunfengcheorderevaluate;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.annotations.*;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.member.controller.app.mpshunfengcheorderevaluate.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.mpshunfengcheorderevaluate.MpShunfengcheOrderEvaluateDO;
import cn.iocoder.yudao.module.member.convert.mpshunfengcheorderevaluate.MpShunfengcheOrderEvaluateConvert;
import cn.iocoder.yudao.module.member.service.mpshunfengcheorderevaluate.MpShunfengcheOrderEvaluateService;

@Api(tags = "用户 APP - 顺风车订单评价")
@RestController
@RequestMapping("/member/mp-shunfengche-order-evaluate")
@Validated
public class AppMpShunfengcheOrderEvaluateController {

    @Resource
    private MpShunfengcheOrderEvaluateService mpShunfengcheOrderEvaluateService;

    @PostMapping("/create")
    @ApiOperation("创建顺风车订单评价")

    public CommonResult<Long> createMpShunfengcheOrderEvaluate(@Valid @RequestBody AppMpShunfengcheOrderEvaluateCreateReqVO createReqVO) {
        return success(mpShunfengcheOrderEvaluateService.createMpShunfengcheOrderEvaluate(createReqVO));
    }

    @PutMapping("/update")
    @ApiOperation("更新顺风车订单评价")

    public CommonResult<Boolean> updateMpShunfengcheOrderEvaluate(@Valid @RequestBody AppMpShunfengcheOrderEvaluateUpdateReqVO updateReqVO) {
        mpShunfengcheOrderEvaluateService.updateMpShunfengcheOrderEvaluate(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @ApiOperation("删除顺风车订单评价")
    @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)

    public CommonResult<Boolean> deleteMpShunfengcheOrderEvaluate(@RequestParam("id") Long id) {
        mpShunfengcheOrderEvaluateService.deleteMpShunfengcheOrderEvaluate(id);
        return success(true);
    }

    @GetMapping("/get")
    @ApiOperation("获得顺风车订单评价")
    @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)

    public CommonResult<AppMpShunfengcheOrderEvaluateRespVO> getMpShunfengcheOrderEvaluate(@RequestParam("id") Long id) {
        MpShunfengcheOrderEvaluateDO mpShunfengcheOrderEvaluate = mpShunfengcheOrderEvaluateService.getMpShunfengcheOrderEvaluate(id);
        return success(MpShunfengcheOrderEvaluateConvert.INSTANCE.convert(mpShunfengcheOrderEvaluate));
    }

    @GetMapping("/list")
    @ApiOperation("获得顺风车订单评价列表")
    @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)

    public CommonResult<List<AppMpShunfengcheOrderEvaluateRespVO>> getMpShunfengcheOrderEvaluateList(@RequestParam("ids") Collection<Long> ids) {
        List<MpShunfengcheOrderEvaluateDO> list = mpShunfengcheOrderEvaluateService.getMpShunfengcheOrderEvaluateList(ids);
        return success(MpShunfengcheOrderEvaluateConvert.INSTANCE.convertList(list));
    }

    @GetMapping("/page")
    @ApiOperation("获得顺风车订单评价分页")

    public CommonResult<PageResult<AppMpShunfengcheOrderEvaluateRespVO>> getMpShunfengcheOrderEvaluatePage(@Valid AppMpShunfengcheOrderEvaluatePageReqVO pageVO) {
        PageResult<MpShunfengcheOrderEvaluateDO> pageResult = mpShunfengcheOrderEvaluateService.getMpShunfengcheOrderEvaluatePage(pageVO);
        return success(MpShunfengcheOrderEvaluateConvert.INSTANCE.convertPage(pageResult));
    }

    @GetMapping("/export-excel")
    @ApiOperation("导出顺风车订单评价 Excel")

    @OperateLog(type = EXPORT)
    public void exportMpShunfengcheOrderEvaluateExcel(@Valid AppMpShunfengcheOrderEvaluateExportReqVO exportReqVO,
              HttpServletResponse response) throws IOException {
        List<MpShunfengcheOrderEvaluateDO> list = mpShunfengcheOrderEvaluateService.getMpShunfengcheOrderEvaluateList(exportReqVO);
        // 导出 Excel
        List<AppMpShunfengcheOrderEvaluateExcelVO> datas = MpShunfengcheOrderEvaluateConvert.INSTANCE.convertList02(list);
        ExcelUtils.write(response, "顺风车订单评价.xls", "数据", AppMpShunfengcheOrderEvaluateExcelVO.class, datas);
    }

}
